package com.wtwd.device.model;

import com.wtwd.device.constant.SeparatorConstant;
import com.wtwd.device.util.ByteUtils;
import com.wtwd.device.util.StringUtils;

import java.io.Serializable;

public class WPhone implements Serializable {

    private static final long serialVersionUID = 1698743446L;


    /**
     * 手机号码
     */
    private String phone;

    /**
     * 名称
     */
    private String name;

    /**
     * 性别 1男  0女
     */
    private int sex;


    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "WPhone{" +
                "phone='" + phone + '\'' +
                ", name='" + name + '\'' +
                ", sex=" + sex +
                '}';
    }

    public String serialization() {
        if (this.name == null) {
            this.name = "";
        }
        if (StringUtils.isEmpty(phone)) {
            this.phone = "0";
        }
        return this.phone + SeparatorConstant.POUND_SIGN + ByteUtils.stringToHex(name) + SeparatorConstant.POUND_SIGN + this.sex;
    }

    public static void main(String[] args) {
        String s = ByteUtils.stringToHex("");
        System.out.println(s);
    }
}
